package com.example.textviewactivity.Fragment;


import android.os.Bundle;

import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;

import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.TextView;

import com.example.textviewactivity.Adapter.ListViewAdapter;
import com.example.textviewactivity.LoginSuccessActivity;
import com.example.textviewactivity.R;
import com.example.textviewactivity.pojo.Account;
import com.example.textviewactivity.pojo.User;

import java.util.ArrayList;
import java.util.List;

/**
 * A simple {@link Fragment} subclass.
 */
public class UserFragment extends Fragment {
//    private String like="";

    ListViewAdapter adapter;
    List<Account> accounts;
    public UserFragment() {
        // Required empty public constructor
    }



    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View view=inflater.inflate(R.layout.fragment_user, container, false);
        ListView listView = view.findViewById(R.id.list_view);
//        TextView tv=view.findViewById(R.id.user);
//        LoginSuccessActivity  activity = (LoginSuccessActivity) getActivity();
//        User user = activity.send();
//        String[] hobby = user.getHobby();
//        for (int i = 0; i < hobby.length; i++) {
//            if (hobby[i]!=null){
//                like+=hobby[i]+",";
//            }
//        }
//        like=like.substring(0,like.length()-1);
//        tv.setText("用户名:"+user.getName()+"\n手机号:"+user.getPhone()+"\n爱好:"+like+"\n性别:"+user.getSex());
        accounts=new ArrayList<>();
        for (int i = 0; i <=30; i++) {
            accounts.add(new Account(R.mipmap.home,"标题"+i,"我是一个没有感情的代码机器"+i,200.0));
        }

        adapter=new ListViewAdapter(accounts,getActivity());
        listView.setAdapter(adapter);
        return view;
    }

}
